Repository navigation
SQL-495: Convert the function system tables to catalog views - #40900
Draft
SangJunBak wants to merge 10 commits into
Draft
SangJunBak wants to merge 10 commits into
SangJunBak wants to merge 10 commits into
Conversation
SangJunBak
force-pushed
the
jun/function-relations
branch
from
November 18, 2026 22:01
80fcf1c to
48b2111
Compare
- Create mz_internal.mz_builtin_types to report builtin types. Essentially a move of the packing code from builtin_table_updates to make_builtin_types. The exception being.... - We extract `from_builtin_oid` from `name_from_oid` to get a mapping from a builtin catalog type to the pgwire typlen. We need `from_builtin_oid` since the builtin table way of getting the postgres type requires the catalog and SQLScalarTypes. This is because user types can be recursive. However our builtin types cannot be and we can use `from_builtin_oid`. To prevent drift, we add a test in catalog.rs that asserts `from_builtin_oid` against types via pgwire.
- Adds decoding code for user types - Converts mz_types, mz_array_types, mz_base_types, mz_list_types, mz_map_types, mz_pseudo_types and mz_type_pg_metadata to builtin views
- Creates tests for each builtin type relations such that it maintains parity with our previous builtin type relations - Creates a test on `try_decode_catalog_create_sql` and assert how errors affect the relation
In postgres, _record has a typlen of -1 rather than NULL and this was previously a bug. Because we use `from_oid` now, this corrects that behavior.
mz_functions, mz_operators and mz_aggregates were builtin tables packed by the adapter from the function registry at every catalog open. They are now views over the generated mz_internal.mz_builtin_functions and mz_internal.mz_builtin_operators views, one row per implementation, with the type names of a signature resolved to catalog ids through mz_builtin_object_mappings. pack_item_update no longer packs rows for functions, catalog open no longer packs a row per operator, and the builtin version pin records the conversion, as does a Replacement step per relation in MIGRATIONS. pg_aggregate declares the oid key it now derives through mz_aggregates. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> resolve rebase conflicts: catalog: define the function and operator relations as views
mz_functions, mz_operators and mz_aggregates became views, so a Drop step at the conversion version sends each of their shards to finalization. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The catalog changes below this one leave every generated test output at
its main version. This change holds all of them for the stack: the
sqllogictest goldens listing builtin objects, their OIDs, columns and
catalog server plans, the two error messages that list the available
relations, and the scalar function registry and LIR snapshots.
ci/test/lint-docs-catalog.py
bin/sqllogictest -- --rewrite-results <files>
REWRITE=1 cargo test -p mz-compute-types --test func_registry
REWRITE=1 cargo test -p mz-compute-types --test lir_schema
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
mz_functions, mz_operators and mz_aggregates are views now, and the two
generated views they read, mz_builtin_functions and mz_builtin_operators,
are new builtins. That adds five EXPLAIN queries to
catalog_server_explain.slt, flips the three relations to VIEW in
information_schema_tables.slt, lists the new views in the autogenerated
mz_internal.slt and oid.slt, and shifts the catalog server index ids by
two. The func_registry and lir_schema snapshots are unchanged.
ci/test/lint-docs-catalog.py
bin/sqllogictest -- --rewrite-results <files>
REWRITE=1 cargo test -p mz-compute-types --test func_registry --test lir_schema
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
resolve rebase conflicts: test: regenerate the goldens for the function relation views
resolve rebase conflicts: test: regenerate the goldens for the function relation views
SangJunBak
force-pushed
the
jun/function-relations
branch
from
November 18, 2026 23:01
48b2111 to
1023d89
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See commit messages for details. These are quite simple builtin table conversions. Since none use the catalog, We get the user custom types from the catalog and the rest statically from our list of builtins.
Motivation
Closes SQL-495
Verification